package vek.XML.Parsers;

import java.util.ArrayList;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import vek.XML.parsedObjects.ParsedObjectInterface;
import vek.XML.parsedObjects.ParsedMuseum;


/**
 * Parses Museum XML files
 * @see XMLParserPOI
 * @author Christian, Michal og Jakob (Hold 1, gruppe 2)
 */
public class XMLParserMuseums extends XMLParserNonComercial implements NonAbstractXMLParserInterface {
    
    //parsing variables
    protected boolean parsingMuseum;
   
    private ArrayList<String> typesOfExhibition = new ArrayList<String>();
    
    private ArrayList<ParsedObjectInterface> museums = new ArrayList<ParsedObjectInterface>();


    @Override
    public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
        
        super.startElement(uri, localName, qName, atts);
        
        if(localName.equals("museum"))
            {
                parsingMuseum = true;
            }
        if(parsingMuseum)
            {
                setTopElementStartTagsRestaurant(uri, localName, qName, atts);
            }
        
    }

    @Override
    public void endElement(String uri, String localName, String qName) throws SAXException {   
        
        super.endElement(uri, localName, qName);
        //System.out.println("elementName from XMLParserMuseums "+localName);
        if(localName.equals("museum"))
            {
                //System.out.println("if loop in XMLParserMuseums has been run!");
                ParsedObjectInterface mus = new ParsedMuseum(ParsedNonComercial, typesOfExhibition);
                museums.add(mus);
            }
        if(parsingMuseum)
            {
                setTopElementEndTagsRestaurant(uri, localName, qName);
                
                if(localName.equals("exhibition"))
                {
                    typesOfExhibition.add(tempElementData);
                }
            }
        
    }

    @Override
    public void characters(char[] ch, int start, int length) throws SAXException {
        
       tempElementData = new String(ch, start, length);
        
    }
    
    private void setTopElementEndTagsRestaurant(String uri, String localName, String qName) throws SAXException 
    {       
       
    }
    
    private void setTopElementStartTagsRestaurant(String uri, String localName, String qName, Attributes atts) throws SAXException
    {
          
    }

    public ArrayList<ParsedObjectInterface> getParsedObjects() 
    {
        return museums;
    }
    

}